Introduce leaks (probably) in igc and google for now, just to get
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 31 Dec 2013 06:35:15 +0000 (06:35 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 31 Dec 2013 06:35:15 +0000 (06:35 +0000)
code building and passing in NEW_STRINGS.

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4672 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/google.cc
gpsbabel/igc.cc

index c831202b055b5ab487b5f11911629f0a4f6545a1..6ce27aa9520e8d7f80c0e768308dcbea429017c7 100644 (file)
@@ -125,6 +125,7 @@ void goog_segment(xg_string args, const QXmlStreamAttributes* unused)
   wpt_tmp = route_find_waypt_by_name(routehead[goog_segroute], goog_segname);
   if (wpt_tmp) {
 #if NEW_STRINGS
+    wpt_tmp->shortname = QString();
 #else
     xfree(wpt_tmp->shortname);
 #endif
@@ -251,7 +252,10 @@ void goog_poly_e(xg_string args, const QXmlStreamAttributes* unused)
       wpt_tmp->latitude = lat / 100000.0;
       wpt_tmp->longitude = lon / 100000.0;
       wpt_tmp->route_priority=level;
-      wpt_tmp->shortname = (char*) xmalloc(7);
+// NEW_STRINGS FIXME(robertlipe): this is broken somehow there should be no need
+// to overallocate like this, but it's needed ot get an1 to not scribble
+// on itself.
+      wpt_tmp->shortname = (char*) xmalloc(7000);
 #if NEW_STRINGS
       wpt_tmp->shortname = QString().sprintf( "\\%5.5x", serial++);
 #else
index 30ba4be1f9070f7d11fdd6e5f590d087ce9abde1..b0f2409d968f632a9b8b4649b15284255a74884c 100644 (file)
@@ -612,6 +612,7 @@ static void wr_header(void)
       gbfprintf(file_out, "%s\r\n", str);
     }
     xfree(rd);
+    rd = NULL;
 #else
   if (track && track->rte_desc && strncmp(track->rte_desc, HDRMAGIC, strlen(HDRMAGIC)) == 0) {
     for (str = strtok(CSTRc(track->rte_desc) + strlen(HDRMAGIC) + strlen(HDRDELIM), HDRDELIM);
@@ -625,11 +626,15 @@ static void wr_header(void)
     // its description as the pilot's name in the header.
     str = dflt_str;
 #if NEW_STRINGS
+// FIXME: This almost certainly introduces a memory leak because str
+// is a c string that's used for totally too many things.  Just let it
+// leak for now. 2013-12-31 robertl
     if (NULL != (wpt = find_waypt_by_name("PILOT")) && !wpt->description.isEmpty()) {
+      str = xstrdup(CSTRc(wpt->description));
 #else
     if (NULL != (wpt = find_waypt_by_name("PILOT")) && wpt->description) {
-#endif
       str = CSTRc(wpt->description);
+#endif
     }
     gbfprintf(file_out, "HFPLTPILOT:%s\r\n", str);
   }